// 源插件
import React, { Fragment, PureComponent } from 'react';
import { DateDiff, DateStamp, FormatnumberZero, Mover, NumberDivide } from '@/function.js';
// 视图插件
import { Button, Card, Divider, Form, message, Modal, notification } from 'antd';
// 外部组件
import PageHeaderWrapper from '@/components/PageHeaderWrapper';
import StandardTablePro from '@/components/UpgradeStandardTable/StandardTablePro';
import { connect } from 'dva';

// css OR less预编译器

// 图片

/**
 *  Describe:数据连接
 */

@connect(({ ubs, loading }) => ({
  ubs,
  loading: loading.models.ubsRule,
}))
@Form.create()
class UbsAll extends PureComponent {
  componentWillMount() {}

  /**
   *  Describe:当前状态
   */

  state = {
    listLoading: false, // 加载状态
    dataSourceAll: {
      data: [],
      total: [],
      code: 0,
    },
    dataSource: {
      data: [],
      total: [],
      code: 0,
    },
    dataSourcePreview: {
      data: [],
      total: [],
      code: 0,
    },
    row: {},
    addVisible: false,
    confirmLoading: false,
  };

  dataSourceChange() {
    const { dispatch } = this.props;
    const that = this;
    dispatch({
      type: 'ubs/GetUBSAccountInfo',
      callback: res => {
        that.setState({
          dataSource: {
            title: `瑞银账户总览 ${
              (res.data[1].children[0].children[0].inserttime || '').split(' ')[0]
            }`,
            code: 1,
            data: res.data,
            total: [],
            titleTotal: false,
            border: false,
            rowKey: 'childAsset',
            columns: [
              /*         {
                         title: '账户',
                         dataIndex: 'accountName',
                         type:'string',
                         // search:true,
                       },
                       {
                         title: '类型',
                         dataIndex: 'typeName',
                         type:'string',
                         // search:true,
                       }, */
              {
                title: '',
                dataIndex: 'childAsset',
                type: 'string',
                width: 150,
                align: 'left',
                // search:true,
              },
              {
                title: '市值',
                dataIndex: 'marketValue',
                type: 'number',
                align: 'right',
              },
              {
                title: '应计利息',
                dataIndex: 'accruedInterest',
                type: 'number',
                align: 'right',
              },
              {
                title: '总计',
                dataIndex: 'total',
                type: 'number',
                align: 'right',
              },
              {
                title: '总资产比重（%）',
                dataIndex: 'totalAssetRatio',
                type: 'number',
                align: 'right',
              },
              {
                title: '今日盈利',
                dataIndex: 'todayProfit',
                type: 'number',
                align: 'right',
              },
            ],
          },
        });
      },
    });
  }

  render() {
    const { addVisible, confirmLoading, row, dataSource, dataSourcePreview } = this.state;
    return (
      <PageHeaderWrapper>
        <Card>
          <StandardTablePro dataSource={dataSource} />
        </Card>
      </PageHeaderWrapper>
    );
  }

  componentDidMount() {
    this.dataSourceChange();
  }

  componentWillUnmount() {}
}

export default UbsAll;
